<?php
include_once('../global.php');
$show = $_GET['show'];
$roundtext = array(
  1 => '第一轮',
  2 => '第二轮',
  3 => '决赛轮',
  4 => '',
);

$user_id=$_SESSION['user_id'];
if(empty($user_id)){//登录操作
    $_SESSION['redirect_url'] = $_SERVER['REQUEST_URI'];
    header('Location: /bmwjunior/mobile/login.php');

// 停止脚本执行
    exit;

}
$type=$_SESSION['type'];
$sql = "SELECT * FROM `bmw_test_drive_sign` WHERE is_del=0 and user_id = '".$user_id."' and type='".$type."'";
$testdrive_list= $db->SelectSQL($sql);
foreach ($testdrive_list as &$v){

    $arr=gettimes($v['type'],$v['time']);
    $v['date']=$arr['date'];
    $v['act_text']=$arr['text'];

}
$active_list=$court_list=[];
if($type==1){
    $sql = "SELECT * FROM `bmw_active_sign_new`  where is_del=0 and  user_id = '".$user_id."' ";
    $active_list= $db->SelectSQL($sql);
    $where=" where o.is_del=0 and  o.user_id = '".$user_id."'";
    //$sql = "SELECT * FROM `bmw_court_order`  where is_del=0 and  user_id = '".$user_id."' ";
    $sql = "SELECT o.*,ot.court_id,ot.date,ot.time FROM `bmw_court_order` o left join bmw_court_order_time ot on o.order_time_id=ot.id  {$where} ";

    $court_list= $db->SelectSQL($sql);

}
?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=GB2312">
  <meta name="viewport"
    content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <link href="<?php echo CSS_PATH ?>index.css" rel="stylesheet" type="text/css">
  <script type="text/javascript" src="<?php echo JS_PATH ?>jquery-1.8.3.min.js"></script>
  <script type="text/javascript" src="<?php echo JS_PATH ?>main.js"></script>
  <title>我的预约-<?php echo $match_cn_name ?></title>

  <style>
    /* 样式优化 */
    body {
      margin: 0;
      padding: 0;
      font-family: Arial, sans-serif;
      background-color: #0d2a35;
      color: white;
      display: flex;
      align-items: center;
      height: 100vh;
      overflow: hidden;
      flex-direction: column;
    }

    .index_news {
      width: 100%;
      padding: 20px;
      box-sizing: border-box;
      overflow-y: auto;
      /* 滑动效果 */
      height: calc(100vh - 10rem);
      /* 限制最大高度为视口高度减去顶部区域的高度 */
      scrollbar-width: thin;
      /* Firefox: 设置滚动条宽度 */
      scrollbar-color: #205763 #0d2a35;
      /* 滚动条颜色 */
    }

    /* Webkit 浏览器滚动条样式 */
    .index_news::-webkit-scrollbar {
      width: 8px;
    }

    .index_news::-webkit-scrollbar-thumb {
      background-color: #205763;
      border-radius: 5px;
    }

    .index_news::-webkit-scrollbar-track {
      background-color: #0d2a35;
    }


    .event-card {
      background-color: #205763;
      border-radius: 10px;
      margin: 10px 0;
      padding: 15px 25px;
      box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    }

    .event-card .event-info {
      flex: 1;
    }

    .event-card .event-info p {
      margin: 0;
      font-size: 16px;
      line-height: 1.5;
    }

    .event-card .event-info p:first-child {
      font-weight: bold;
    }

    #sta {
      width: 100%;
      padding: 10px;
      box-sizing: border-box;
      text-align: center;
    }

    #sta img {
      width: 250px;
      height: auto;
    }
  

/* Webkit 浏览器滚动条样式 */
.index_news::-webkit-scrollbar {
    width: 8px;
}
.index_news::-webkit-scrollbar-thumb {
    background-color: #205763;
    border-radius: 5px;
}
.index_news::-webkit-scrollbar-track {
    background-color: #0d2a35;
}

.event-card {
    background-color: #2F6064;
    border-radius: 10px;
    margin: 10px 0;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    color: #fff;
}

.event-card .title {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 10px;
}

.event-card .detail {
    font-size: 14px;
    color: #fff;
    line-height: 1.8;
}
  </style>
</head>

<body>
  <div id="sta">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tbody>
        <tr>
          <td style="text-align:center;"><img src="./images/000.png" style="width:350px;height:80px" /></td>
        </tr>
      </tbody>
    </table>
  </div>
  <div class="index_news poppin">

      <?php if ($active_list) { ?>
      <?php foreach ($active_list as $val) { ?>
                  <?php if($val['act_id']==1){?>
                      <?php
                  $session_arr=explode(",",$val['session']);
                  ?>
            <!-- 冠军训练营 -->
            <div class="event-card">
                <p class="title">冠军训练营</p>


                <p class="detail">时间：<?php echo get_active($val['session']);?></p>

                <p class="detail">地点：东莞观澜湖高尔夫球会山顶练习场</p>
<!--                <p class="detail">集合点：观景台（出发站对面）</p>-->
            </div>
              <?php }?>

              <?php if($val['act_id']==3){?>
                  <!-- 成长之路家长分享会 -->
                  <div class="event-card">
                      <p class="title">成长之路家长分享会</p>
                      <p class="detail">时间：<?php echo get_jiazhang_active($val['session']);?></p>
                      <p class="detail">地点：东莞观澜湖度假酒店 尊尚酒廊</p>
                  </div>
              <?php }?>
          <?php } ?>
      <?php } ?>
    <!-- 试乘试驾 -->
      <?php if ($testdrive_list) { ?>
      <?php foreach ($testdrive_list as $v) { ?>
    <div class="event-card">
        <p class="title">试乘试驾</p>
        <p class="detail">体验：<?php echo   str_replace('I', 'i', $v['testtype'])." ".$v['selecttype']; ?></p>
        <p class="detail">时间：<?php echo $v['date']; ?></p>
        <p class="detail">路线：<?php echo $v['act_text']; ?></p>
        <p class="detail">签到地点：东莞观澜湖度假酒店  大堂</p>
    </div>
          <?php } ?>
      <?php } ?>

      <!-- 场地预约-->
      <?php if ($court_list) { ?>
          <?php foreach ($court_list as $v1) { ?>
                  <?php $court_info=get_court_text($v1);?>
              <div class="event-card <?php echo $v1['id'];?>">
                  <p class="title">预约试场</p>
                  <p class="detail">时间：<?php echo $court_info['date']; ?> <?php echo $court_info['time']; ?></p>
                  <p class="detail"><?php echo $court_info['court_name']; ?> <?php echo $court_info['dong_name']; ?></p>
              </div>
          <?php } ?>
      <?php } ?>


</div>

 
  <?php if($type==2){ ?>
      <a href="/bmwjunior/mobile/logout.php" style="text-decoration:none;color:#fff;">
          <div style="width:260px;height:50px;margin-left:auto;margin-top:40px;display:flex;justify-content:center;margin-right:auto;
		align-items:center; font-size:22px;border-radius:10px;border:2px solid #fff;margin-bottom:30px;
		">注销</div></a>
  <?php }else{ ?>
  <div class="bottommenu">
  <div class="<?php echo $css_class; ?>" onclick="gotomain()"><?php echo t('back'); ?></div>    <div class="<?php echo $css_class; ?>" onclick="gotomain()"><?php echo t('home_page'); ?></div> 
  </div>
<?php } ?>
</body>

<script>

  function goback() {
    window.history.back();
  }


  function gotomain() {
      window.location = './main.php';
    }
</script>

</html>